﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Commandparser.Types
{
    sealed class @array : IPropertyObject
    {
        public List<string> Values { get; set; }

        public @array()
        {
            Values = new List<string>();

            Value = ToString();
        }

        public override IPropertyObject Parse(string content)
        {
            var returns = new @array();

            foreach (var v in Middle(content, "[", "]").Split(Convert.ToChar(",")))
            {
                returns.Values.Add(v);
            }

            return returns;
        }

        public override bool IsType(string content)
        {
            if(content.StartsWith("[") && content.EndsWith("]"))
            {
                return true;
            }
           
            return base.IsType(content);
        }

    }
}
